<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>lpfreson</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="lpf18.html" title="lpf18" />
    <link rel="next" href="lphasor.html" title="lphasor" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">lpfreson</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="lpf18.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="lphasor.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="lpfreson"></a>
      <div class="titlepage"></div>
      <a id="IndexLpfreson" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">lpfreson</span>
        </h2>
        <p>lpfreson — 
      Resynthesises a signal from the data passed internally by a previous lpread, applying formant shifting.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121126400"></a>
        <h2>Description</h2>
        <p>
      Resynthesises a signal from the data passed internally by a previous <span class="emphasis"><em>lpread</em></span>, applying formant shifting.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121128096"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>lpfreson</strong></span> asig, kfrqratio</pre>
      </div>
      <div class="refsect1">
        <a id="idp121199136"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>asig</em></span> -- an audio driving function for resynthesis.
    </p>
        <p>
      <span class="emphasis"><em>kfrqratio</em></span> -- frequency ratio. Must be greater than 0.
    </p>
        <p>
      <span class="emphasis"><em>lpfreson</em></span> receives values internally produced by a leading <span class="emphasis"><em>lpread</em></span>.<span class="emphasis"><em>lpread</em></span> gets its values from the control file according to the input value <span class="emphasis"><em>ktimpnt</em></span> (in seconds). If <span class="emphasis"><em>ktimpnt</em></span> proceeds at the analysis rate, time-normal synthesis will result; proceeding at a faster, slower, or variable rate will result in time-warped synthesis. At each k-period, <span class="emphasis"><em>lpread</em></span> interpolates between adjacent frames to more accurately determine the parameter values (presented as output) and the filter coefficient settings (passed internally to a subsequent <span class="emphasis"><em>lpreson</em></span>).
    </p>
        <p>The error signal <span class="emphasis"><em>kerr</em></span> (between 0 and 1) derived during predictive analysis reflects the deterministic/random nature of the analyzed source. This will emerge low for pitched (periodic) material and higher for noisy material. The transition from voiced to unvoiced speech, for example, produces an error signal value of about .3. During synthesis, the error signal value can be used to determine the nature of the <a class="link" href="lpreson.html" title="lpreson"><em class="citetitle">lpreson</em></a> driving function: for example, by arbitrating between pitched and non-pitched input, or even by determining a mix of the two. In normal speech resynthesis, the pitched input to <a class="link" href="lpreson.html" title="lpreson"><em class="citetitle">lpreson</em></a> is a wideband periodic signal or pulse train derived from a unit such as <a class="link" href="buzz.html" title="buzz"><em class="citetitle">buzz</em></a>, and the nonpitched source is usually derived from <a class="link" href="rand.html" title="rand"><em class="citetitle">rand</em></a>. However, any audio signal can be used as the driving function, the only assumption of the analysis being that it has a flat response.
    </p>
        <p><span class="emphasis"><em>lpfreson</em></span> is a formant shifted <a class="link" href="lpreson.html" title="lpreson"><em class="citetitle">lpreson</em></a>, in which <span class="emphasis"><em>kfrqratio</em></span> is the (cps) ratio of shifted to original formant positions. This permits synthesis in which the source object changes its apparent acoustic size. <span class="emphasis"><em>lpfreson</em></span> with <span class="emphasis"><em>kfrqratio</em></span> = 1 is equivalent to <a class="link" href="lpreson.html" title="lpreson"><em class="citetitle">lpreson</em></a>.
    </p>
        <p>Generally, <a class="link" href="lpreson.html" title="lpreson"><em class="citetitle">lpreson</em></a> provides a means whereby the time-varying content and spectral shaping of a composite audio signal can be controlled by the dynamic spectral content of another. There can be any number of <span class="emphasis"><em>lpread/lpreson</em></span> (or <span class="emphasis"><em>lpfreson</em></span>) pairs in an instrument or in an orchestra; they can read from the same or different control files independently.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121217520"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the lpfreson opcode. It uses the file <a class="ulink" href="examples/lpfreson.csd" target="_top"><em class="citetitle">lpfreson.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp121219376"></a>
          <p class="title">
            <strong>Example 451. Example of the lpfreson opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o lpfreson.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1
<span class="comment">;do not use -a option when analyzing "fox.wav" with lpfreson,</span>
<span class="comment">;it needs a filter coefficient type of file</span>
<span class="oblock">instr</span> 1

ilen  <span class="opc">filelen</span> "fox.wav"	<span class="comment">; length of soundfile</span>
<span class="opc">prints</span> "fox.wav <span class="op">=</span> <span class="op">%</span>f seconds\\n",ilen

ktime <span class="opc">line</span> 0, p3, p4
krmsr,krmso,kerr,kcps <span class="opc">lpread</span> ktime,"fox_nopoles.lpc"
krmso <span class="op">=</span> krmso<span class="op">*</span>.00001			<span class="comment">; low volume</span>
asig  <span class="opc">buzz</span> krmso, kcps, <span class="opc">int</span>(<span class="ohdr">sr</span><span class="op">/</span>2<span class="op">/</span>kcps), 1 <span class="comment">; max harmonics without aliasing</span>
aout  <span class="opc">lpfreson</span> asig, 1.2
asig  <span class="opc">clip</span> aout, 0, 1			<span class="comment">; prevents distortion</span>
      <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">; sine</span>
<span class="stamnt">f</span>1 0 4096 10 1

<span class="stamnt">i</span> 1 0 2.8 1	<span class="comment">; first words only</span>
<span class="stamnt">i</span> 1 4 2.8 2.8	<span class="comment">; whole sentence</span>
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
      The audio file <span class="quote">“<span class="quote">fox.wav</span>”</span> is 2.8 seconds long. So <span class="emphasis"><em>filelen</em></span>'s output should be a line like this:
      </p>
        <pre class="screen">
fox.wav = 2.756667 seconds
      </pre>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121225280"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="lpread.html" title="lpread"><em class="citetitle">lpread</em></a>,
      <a class="link" href="lpreson.html" title="lpreson"><em class="citetitle">lpreson</em></a>
    </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="lpf18.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="lphasor.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">lpf18 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> lphasor</td>
        </tr>
      </table>
    </div>
  </body>
</html>
